{include file="public/_meta" title="系统配置"/}
<style>
	.file {
		position: relative;
		display: inline-block;
		background: #D0EEFF;
		border: 1px solid #99D3F5;
		border-radius: 4px;
		padding: 4px 12px;
		overflow: hidden;
		color: #1E88C7;
		text-decoration: none;
		text-indent: 0;
		line-height: 20px;
	}
	.file input {
		position: absolute;
		font-size: 100px;
		right: 0;
		top: 0;
		opacity: 0;
	}
	.file:hover {
		background: #AADFFD;
		border-color: #78C3F3;
		color: #004974;
		text-decoration: none;
	}
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>
	系统管理
	<span class="c-gray en">&gt;</span>
	系统配置
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
	<form method="post" action="" class="form form-horizontal" id="form-system-config">
		<div id="tab-system" class="HuiTab">
			<div class="tabBar cl">
				<!--<span>基本设置</span>
				<span>邮件设置</span>
				<span>SEO设置</span>-->
				{volist id="vo" name="system_menu"}
					<span>{$vo}</span>
				{/volist}
			</div>

			{volist id="vo" name="system_menu"}
			<div class="tabCon">
				<?php foreach( $list as $k => $v):?>
				<?php if($v['config_category']==$key):?>
				<?php if($v['config_type'] == 1):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
						<!-- 单行文本 -->
						<input type="text" value="<?php echo $v['default_value'];?>" name="<?php echo $v['en_name'];?>" class="input-text">
					</div>
				</div>
				<?php endif;?>

				<?php if($v['config_type'] == 2):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
						<?php
							$optional_value = explode(',', $v['optional_value']);
							foreach($optional_value as $k1 => $v1):
						?>

						<!-- 单选按钮 -->
						<div style="float:left; padding-left:10px;">
							<input type="radio"  {if condition="$v1 eq $v['default_value']"} checked="checked" {/if}  value="<?php echo $v1;?>" name="<?php echo $v['en_name'];?>" > <span><?php echo $v1;?></span>
						</div>
						<?php endforeach;?>
					</div>
				</div>
				<?php endif;?>

				<?php if($v['config_type'] == 3):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
						<?php
									$optional_value = explode(',', $v['optional_value']);
									$default_value = explode(',', $v['default_value']);
									foreach($optional_value as $k1 => $v1):
						?>
						<!-- 复选按钮 -->
						<div style="float:left; padding-left:10px;">
							<input name="<?php echo $v['en_name'];?>[]" <?php if(in_array($v1, $default_value)){echo 'checked="checked"';}?> value="<?php echo $v1;?>" type="checkbox">
							<span><?php echo $v1;?></span>
						</div>
						<?php endforeach;?>
					</div>
				</div>
				<?php endif;?>

				<?php if($v['config_type'] == 4):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
								<span class="select-box">
									<select name="<?php echo $v['en_name'];?>" class="select">
								<?php
									$optional_value = explode(',', $v['optional_value']);
									foreach($optional_value as $k1 => $v1):
								?>
										<!-- 下拉列表 -->
										<option <?php if($v1==$v['default_value']){echo 'selected="selected"';}?> value="<?php echo $v1;?>"><?php echo $v1;?></option>
										<?php endforeach;?>
									</select>
								</span>
					</div>
				</div>
				<?php endif;?>

				<?php if($v['config_type'] == 5):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
						<!-- 文本域 -->
						<textarea name="<?php echo $v['en_name'];?>" class="textarea"> <?php echo $v['default_value'];?> </textarea>
					</div>
				</div>
				<?php endif;?>

				<?php if($v['config_type'] == 6):?>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
					<div class="formControls col-xs-8 col-sm-9">
						<!-- 附件 -->
						<a href="javascript:;" class="file">选择文件
							<input class="upload_images" style="float:left;" value="" name="<?php echo $v['en_name'];?>" type="file">
						</a>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"></label>
					<div class="formControls col-xs-8 col-sm-9">
						{if condition="$v['default_value']"}<img id="<?php echo $v['en_name'];?>" height="50" src="__PUBLIC__{$v.default_value}">{else /}<img style="display:none" id="<?php echo $v['en_name'];?>" height="50"/>{/if}
					</div>
				</div>
				<?php endif;?>
				<?php endif;?>
				<?php endforeach;?>
			</div>
			{/volist}

			<!--<div class="tabCon">
				<?php foreach( $list as $k => $v):?>
				<?php if($v['config_category']==1):?>
					<?php if($v['config_type'] == 1):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
								&lt;!&ndash; 单行文本 &ndash;&gt;
								<input type="text" value="<?php echo $v['default_value'];?>" name="<?php echo $v['en_name'];?>" class="input-text">
							</div>
						</div>
					<?php endif;?>

					<?php if($v['config_type'] == 2):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
						<?php
							$optional_value = explode(',', $v['optional_value']);
							foreach($optional_value as $k1 => $v1):
						?>

							&lt;!&ndash; 单选按钮 &ndash;&gt;
							<div style="float:left; padding-left:10px;">
								<input type="radio"  {if condition="$v1 eq $v['default_value']"} checked="checked" {/if}  value="<?php echo $v1;?>" name="<?php echo $v['en_name'];?>" > <span><?php echo $v1;?></span>
							</div>
					<?php endforeach;?>
							</div>
						</div>
					<?php endif;?>

					<?php if($v['config_type'] == 3):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
								<?php
									$optional_value = explode(',', $v['optional_value']);
									$default_value = explode(',', $v['default_value']);
									foreach($optional_value as $k1 => $v1):
								?>
								&lt;!&ndash; 复选按钮 &ndash;&gt;
								<div style="float:left; padding-left:10px;">
									<input name="<?php echo $v['en_name'];?>[]" <?php if(in_array($v1, $default_value)){echo 'checked="checked"';}?> value="<?php echo $v1;?>" type="checkbox">
									<span><?php echo $v1;?></span>
								</div>
								<?php endforeach;?>
							</div>
						</div>
					<?php endif;?>

					<?php if($v['config_type'] == 4):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
								<span class="select-box">
									<select name="<?php echo $v['en_name'];?>" class="select">
								<?php
									$optional_value = explode(',', $v['optional_value']);
									foreach($optional_value as $k1 => $v1):
								?>
								&lt;!&ndash; 下拉列表 &ndash;&gt;
										<option <?php if($v1==$v['default_value']){echo 'selected="selected"';}?> value="<?php echo $v1;?>"><?php echo $v1;?></option>
								<?php endforeach;?>
									</select>
								</span>
							</div>
						</div>
					<?php endif;?>

					<?php if($v['config_type'] == 5):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
								&lt;!&ndash; 文本域 &ndash;&gt;
								<textarea name="<?php echo $v['en_name'];?>" class="textarea"> <?php echo $v['default_value'];?> </textarea>
							</div>
						</div>
					<?php endif;?>

					<?php if($v['config_type'] == 6):?>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
							<div class="formControls col-xs-8 col-sm-9">
								&lt;!&ndash; 附件 &ndash;&gt;
								<a href="javascript:;" class="file">选择文件
									<input class="upload_images" style="float:left;" value="" name="<?php echo $v['en_name'];?>" type="file">
								</a>
							</div>
						</div>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-2"></label>
							<div class="formControls col-xs-8 col-sm-9">
								{if condition="$v['default_value']"}<img id="<?php echo $v['en_name'];?>" height="50" src="__PUBLIC__{$v.default_value}">{else /}<img style="display:none" id="<?php echo $v['en_name'];?>" height="50"/>{/if}
							</div>
						</div>
					<?php endif;?>
				<?php endif;?>
			<?php endforeach;?>
		</div>
		<div class="tabCon">
			<?php foreach( $list as $k => $v):?>
			<?php if($v['config_category']==2):?>
			<?php if($v['config_type'] == 1):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 单行文本 &ndash;&gt;
					<input type="text" value="<?php echo $v['default_value'];?>" name="<?php echo $v['en_name'];?>" class="input-text">
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 2):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					<?php
						$optional_value = explode(',', $v['optional_value']);
						foreach($optional_value as $k1 => $v1):
					?>

					&lt;!&ndash; 单选按钮 &ndash;&gt;
					<div style="float:left; padding-left:10px;">
						<input type="radio"  {if condition="$v1 eq $v['default_value']"} checked="checked" {/if}  value="<?php echo $v1;?>" name="<?php echo $v['en_name'];?>" > <span><?php echo $v1;?></span>
					</div>
					<?php endforeach;?>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 3):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					<?php
								$optional_value = explode(',', $v['optional_value']);
								$default_value = explode(',', $v['default_value']);
								foreach($optional_value as $k1 => $v1):
					?>
					&lt;!&ndash; 复选按钮 &ndash;&gt;
					<div style="float:left; padding-left:10px;">
						<input name="<?php echo $v['en_name'];?>[]" <?php if(in_array($v1, $default_value)){echo 'checked="checked"';}?> value="<?php echo $v1;?>" type="checkbox">
						<span><?php echo $v1;?></span>
					</div>
					<?php endforeach;?>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 4):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
							<span class="select-box">
								<select name="<?php echo $v['en_name'];?>" class="select">
							<?php
								$optional_value = explode(',', $v['optional_value']);
								foreach($optional_value as $k1 => $v1):
							?>
									&lt;!&ndash; 下拉列表 &ndash;&gt;
									<option <?php if($v1==$v['default_value']){echo 'selected="selected"';}?> value="<?php echo $v1;?>"><?php echo $v1;?></option>
									<?php endforeach;?>
								</select>
							</span>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 5):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 文本域 &ndash;&gt;
					<textarea name="<?php echo $v['en_name'];?>" class="textarea"> <?php echo $v['default_value'];?> </textarea>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 6):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 附件 &ndash;&gt;
					<a href="javascript:;" class="file">选择文件
						<input class="upload_images" style="float:left;" value="" name="<?php echo $v['en_name'];?>" type="file">
					</a>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"></label>
				<div class="formControls col-xs-8 col-sm-9">
					{if condition="$v['default_value']"}<img id="<?php echo $v['en_name'];?>" height="50" src="__PUBLIC__{$v.default_value}">{else /}<img style="display:none" id="<?php echo $v['en_name'];?>" height="50"/>{/if}
				</div>
			</div>
			<?php endif;?>
			<?php endif;?>
			<?php endforeach;?>
		</div>
		<div class="tabCon">
			<?php foreach( $list as $k => $v):?>
			<?php if($v['config_category']==3):?>
			<?php if($v['config_type'] == 1):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 单行文本 &ndash;&gt;
					<input type="text" value="<?php echo $v['default_value'];?>" name="<?php echo $v['en_name'];?>" class="input-text">
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 2):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					<?php
						$optional_value = explode(',', $v['optional_value']);
						foreach($optional_value as $k1 => $v1):
					?>

					&lt;!&ndash; 单选按钮 &ndash;&gt;
					<div style="float:left; padding-left:10px;">
						<input type="radio"  {if condition="$v1 eq $v['default_value']"} checked="checked" {/if}  value="<?php echo $v1;?>" name="<?php echo $v['en_name'];?>" > <span><?php echo $v1;?></span>
					</div>
					<?php endforeach;?>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 3):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					<?php
						$optional_value = explode(',', $v['optional_value']);
						$default_value = explode(',', $v['default_value']);
						foreach($optional_value as $k1 => $v1):
					?>
					&lt;!&ndash; 复选按钮 &ndash;&gt;
					<div style="float:left; padding-left:10px;">
						<input name="<?php echo $v['en_name'];?>[]" <?php if(in_array($v1, $default_value)){echo 'checked="checked"';}?> value="<?php echo $v1;?>" type="checkbox">
						<span><?php echo $v1;?></span>
					</div>
					<?php endforeach;?>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 4):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
							<span class="select-box">
								<select name="<?php echo $v['en_name'];?>" class="select">
							<?php
								$optional_value = explode(',', $v['optional_value']);
								foreach($optional_value as $k1 => $v1):
							?>
									&lt;!&ndash; 下拉列表 &ndash;&gt;
									<option <?php if($v1==$v['default_value']){echo 'selected="selected"';}?> value="<?php echo $v1;?>"><?php echo $v1;?></option>
									<?php endforeach;?>
								</select>
							</span>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 5):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 文本域 &ndash;&gt;
					<textarea name="<?php echo $v['en_name'];?>" class="textarea"> <?php echo $v['default_value'];?> </textarea>
				</div>
			</div>
			<?php endif;?>

			<?php if($v['config_type'] == 6):?>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><?php echo $v['ch_name'];?></label>
				<div class="formControls col-xs-8 col-sm-9">
					&lt;!&ndash; 附件 &ndash;&gt;
					<a href="javascript:;" class="file">选择文件
						<input class="upload_images" style="float:left;" value="" name="<?php echo $v['en_name'];?>" type="file">
					</a>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"></label>
				<div class="formControls col-xs-8 col-sm-9">
					{if condition="$v['default_value']"}<img id="<?php echo $v['en_name'];?>" height="50" src="__PUBLIC__{$v.default_value}" />{else /}<img style="display:none" id="<?php echo $v['en_name'];?>" height="50"/>{/if}
				</div>
			</div>
			<?php endif;?>
			<?php endif;?>
			<?php endforeach;?>
		</div>-->
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
			<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
			<button class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
		</div>
	</div>
	</form>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#tab-system").Huitab({
            index:0
        });
        $("#form-system-config").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var data = $(form).serializeArray;
                $(form).ajaxSubmit({
                    url : "{:url('system/system_config')}",
                    type : 'post',
                    dataType : 'json',
                    data : data,
                    async : false,
                    success : function(msg){
                        if(msg.status == true){
                            layer.msg(msg.message,{icon: 6,time:1000});
                            setTimeout(jump,1000);
                            function jump(){
                                window.location.reload();
                            }
                        }else if(msg.status == false){
                            layer.msg(msg.message,{icon: 5,time:1000});
                        }
                    }
                });
            }
        });
    });


    //上传图片显示
	$('.upload_images').change(function() {
        var file = $(this);
        var fileObj = file[0];
        var id = fileObj.name;
        var windowURL = window.URL || window.webkitURL;
        var dataURL;
        var img = $('#'+id);
        img.css('display','inline-block');
        if(fileObj && fileObj.files && fileObj.files[0]){
            dataURL = windowURL.createObjectURL(fileObj.files[0]);
            img.attr('src',dataURL);
        }else{
            dataURL = $file.val();
            var imgObj = document.getElementById(id);
            imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
            imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
        }
    });
</script>
